<template>
  <el-aside ref="tAside">
    <el-button
      style="width: 25%; height: 48px"
      @click="changeStretch"
      v-if="isStretch"
      :icon="Fold"
    ></el-button>
    <el-button
      style="width: 100%; height: 48px"
      @click="changeStretch"
      v-if="!isStretch"
      :icon="Expand"
    ></el-button>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      :collapse="isStretch"
      @open="handleOpen"
      @close="handleClose"
    >
      <el-sub-menu index="1">
        <template #title>
          <el-icon><location /></el-icon>
          <span>Navigator One</span>
        </template>
        <el-menu-item-group>
          <template #title><span>Group One</span></template>
          <el-menu-item index="1-1">item one</el-menu-item>
          <el-menu-item index="1-2">item two</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="Group Two">
          <el-menu-item index="1-3">item three</el-menu-item>
        </el-menu-item-group>
        <el-sub-menu index="1-4">
          <template #title><span>item four</span></template>
          <el-menu-item index="1-4-1">item one</el-menu-item>
        </el-sub-menu>
      </el-sub-menu>
      <el-menu-item index="2">
        <el-icon><icon-menu /></el-icon>
        <template #title>Navigator Two</template>
      </el-menu-item>
      <el-menu-item index="3" disabled>
        <el-icon><document /></el-icon>
        <template #title>Navigator Three</template>
      </el-menu-item>
      <el-menu-item index="4">
        <el-icon><setting /></el-icon>
        <template #title>Navigator Four</template>
      </el-menu-item>
    </el-menu>
  </el-aside>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import {
  Expand,
  Fold,
  Menu as IconMenu,
  Location,
  Document,
  Setting,
} from "@element-plus/icons-vue";
const tAside = ref();
let icon: any = ref(Expand);
const isStretch = ref(false);
const stretch = ref("<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
const handleOpen = (key: string, keyPath: string[]) => {
  // console.log(key, keyPath);
};
const handleClose = (key: string, keyPath: string[]) => {
  // console.log(key, keyPath);
};
const changeStretch = () => {
  if (isStretch.value) {
    icon = Expand;
  } else {
    icon = Fold;
  }
  console.log(icon);
  isStretch.value = !isStretch.value;
};
onMounted(() => {
  // 加载完成获取input焦点
  // 打印多个ref DOM
  tAside.value.style.width = 1800;
  console.log(tAside.value.style.width);
});
</script>

<style lang="scss" scoped>
.el-menu--collapse {
  width: 25%;
  padding: 0 2.5%;
}
</style>